package com.ebs.md.fxmonitor.marketmonitor.rulesfilter;

import java.util.Map;

import com.ebs.md.fxmonitor.marketmonitor.config.IEventConfigProvider;
import com.ebs.md.persistence.Filter;

public class TopOfBooksChangePersistFilter implements Filter{

	private IEventConfigProvider eventConfigProvider;

	@Override
	public boolean isValid(Map<String, Object> data) {
    	boolean isPersistencePair = true;
    	Object  baseCurrencyIso = null; 
    	Object localCurrencyIso = null;

    	if (data != null)
    	{
        	 baseCurrencyIso = data.get( "base_ccy_iso"); 
        	localCurrencyIso = data.get("local_ccy_iso");
    	}
    	
    	if ( (eventConfigProvider != null ) && 
    		 (    baseCurrencyIso != null ) &&
    		 (   localCurrencyIso != null )    )
    	{
    		isPersistencePair = !eventConfigProvider.isTopOfBookPersistencePairsBlackListed( baseCurrencyIso.toString(), localCurrencyIso.toString());
    	}
    	
    	return isPersistencePair;
	}

	public void setEventConfigProvider(IEventConfigProvider eventConfigProvider) {
		this.eventConfigProvider = eventConfigProvider;
	}

}
